]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
volume: Allow volume above 100%
authorDidier Roche <didrocks@ubuntu.com>
Tue, 31 Jul 2018 06:02:04 +0000 (08:02 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 31 Jul 2018 18:14:13 +0000 (18:14 +0000)
Depending on hardware and recorded volume level, turning up the speakers
to the maximum volume may not be enough and the user will want to amplify
the volume above 100%. Currently this requires opening the sound Settings
panel which gets cumbersome when required repeatedly.

To support this case better, allow raising the sound volume above 100%
directly from the system menu if the feature is enabled via the
`allow-volume-above-100-percent` key in `org.gnome.desktop.sound`.

js/ui/status/volume.js
meson.build

index d814ef6654df2dedb30ee1984b6c3c929901276b..b337e752d9cafb6c776c23874e73057171c249c8 100644 (file)
@@ -12,6 +12,8 @@ const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 const Slider = imports.ui.slider;
 
+const ALLOW_AMPLIFIED_VOLUME_KEY = 'allow-volume-above-100-percent';
+
 var VOLUME_NOTIFY_ID = 1;
 
 // Each Gvc.MixerControl is a connection to PulseAudio,
@@ -36,6 +38,11 @@ var StreamSlider = new Lang.Class({
         this.item = new PopupMenu.PopupBaseMenuItem({ activate: false });
 
         this._slider = new Slider.Slider(0);
+
+        this._soundSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.sound' });
+        this._soundSettings.connect('changed::' + ALLOW_AMPLIFIED_VOLUME_KEY, this._amplifySettingsChanged.bind(this));
+        this._amplifySettingsChanged();
+
         this._slider.connect('value-changed', this._sliderChanged.bind(this));
         this._slider.connect('drag-end', this._notifyVolumeChange.bind(this));
 
@@ -135,6 +142,18 @@ var StreamSlider = new Lang.Class({
         this.emit('stream-updated');
     },
 
+    _amplifySettingsChanged() {
+        this._allowAmplified = this._soundSettings.get_boolean(ALLOW_AMPLIFIED_VOLUME_KEY);
+
+        if (this._allowAmplified)
+            this._slider.setMaximumValue(this.getMaxLevel() / 100);
+        else
+            this._slider.setMaximumValue(1);
+
+        if (this._stream)
+            this._updateVolume();
+    },
+
     getIcon() {
         if (!this._stream)
             return null;
@@ -157,6 +176,14 @@ var StreamSlider = new Lang.Class({
             return null;
 
         return 100 * this._stream.volume / this._control.get_vol_max_norm();
+    },
+
+    getMaxLevel() {
+        let maxVolume = this._control.get_vol_max_norm();
+        if (this._allowAmplified)
+            maxVolume = this._control.get_vol_max_amplified();
+
+        return 100 * maxVolume / this._control.get_vol_max_norm();
     }
 });
 Signals.addSignalMethods(StreamSlider.prototype);
@@ -310,6 +337,10 @@ var VolumeMenu = new Lang.Class({
 
     getLevel() {
         return this._output.getLevel();
+    },
+
+    getMaxLevel() {
+        return this._output.getMaxLevel();
     }
 });
 
@@ -346,8 +377,9 @@ var Indicator = new Lang.Class({
             return result;
 
         let gicon = new Gio.ThemedIcon({ name: this._volumeMenu.getIcon() });
-        let level = this._volumeMenu.getLevel();
-        Main.osdWindowManager.show(-1, gicon, null, level);
+        let level = parseInt(this._volumeMenu.getLevel());
+        let maxLevel = parseInt(this._volumeMenu.getMaxLevel());
+        Main.osdWindowManager.show(-1, gicon, null, level, maxLevel);
         return result;
     }
 });
index cafba27a82538b0c9320ab3f39388e63d610e397..ad513a6659739616fd2e230c8a4a7cfcb58d98f2 100644 (file)
@@ -25,7 +25,7 @@ gtk_req = '>= 3.15.0'
 json_glib_req = '>= 0.13.2'
 mutter_req = '>= 3.29.4'
 polkit_req = '>= 0.100'
-schemas_req = '>= 3.21.3'
+schemas_req = '>= 3.27.90'
 startup_req = '>= 0.11'
 ibus_req = '>= 1.5.2'